package org.ly817.falsework.dubbo.gateway.boot.web.rest;

import com.alibaba.dubbo.config.annotation.Reference;
import org.apache.http.client.HttpClient;
import org.apache.http.client.methods.HttpGet;
import org.ly817.falsework.api.entity.User;
import org.ly817.falsework.api.service.UserService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.io.IOException;

/**
 * @author LuoYu
 * @date 2018/07/27 9:00
 * <p>
 * Description:
 * REST demo controller
 */
@RestController
@RequestMapping("/rest/demo")
public class DemoController {
    private final Logger logger = LoggerFactory.getLogger(DemoController.class);

    @Reference
    private UserService userService;

    @Autowired
    private HttpClient httpClient;

    @GetMapping("/test")
    public User test() {
        try {
            System.out.println(httpClient.execute(new HttpGet("http://www.baidu.com")).getEntity());
        } catch (IOException e) {
            e.printStackTrace();
        }
        return userService.test(new User());
    }
}
